<template>
  <div class="app-container">
    <el-row type="flex" align="center" :gutter="20">
      <el-form class="filterData-block" label-position="left" :inline="true" label-width="auto">

      </el-form>
    </el-row>
    <el-row style="margin-top: 20px">
      <el-table v-loading="tableConf.loading" :stripe="true" :border="true" :data="tableData">
        <el-table-column align="center" width="50px" prop="id" label="ID"/>
        <el-table-column align="center" min-width="100px" prop="enterpriseName" label="企业"/>
        <el-table-column align="center" min-width="100px" prop="legalPersonName" label="法人"/>
        <el-table-column align="center" min-width="100px" prop="crtTime" label="注册时间"/>
      </el-table>
    </el-row>
    <el-row style="margin-top: 20px">
      <el-pagination
        :page-sizes="tableConf.sizes"
        :page-size="tableConf.size"
        :total="tableConf.total"
        :current-page="tableConf.page"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-row>

  </div>
</template>

<script>
import PersonnelCodeDetail from '@/components/PersonnelCode/Detail'
import DetailHelpContent from '@/components/QuestionCode/DetailHelpContent'
import {getHelpListApi} from "@/api/QuestionnaireInvestigation";
import {getComByStreetIdApi, getCustomerByStreetIdApi} from "@/api/customer";

export default {
  components: { PersonnelCodeDetail,DetailHelpContent },
  data() {
    return {
      tableData: [],
      tableConf: {
        page: 1,
        sizes: [5, 20, 50, 100],
        total: 0,
        size: 5,
        loading: false
      },
      visible: {//控制弹窗显示
        0: false
      },
      detailId: null,
      placeTypeLoading: true,
    }
  },
  props:['id','time','closeDialog'],
  mounted() {
    this.createParams(this)
    this.getTableList()
  },
  methods: {
    //打开添加/编辑页
    openDetail(id = null,index) {
      this.detailId = id
      this.visible[index] = true
    },
    //关闭指定弹窗并刷新页面
    closeDialogSon(index) {
      this.visible[index] = false
      this.getTableList()
    },
    openRecord(id) {
      //新标签页打开列表
      this.$router.push({
        name: 'PlaceScanRecord',
        query: {
          id: id
        }
      })
    },
    // 每页显示数量change
    handleSizeChange(e) {
      this.tableConf.size = e
      this.getTableList()
    },
    // 当前页change
    handleCurrentChange(e) {
      this.tableConf.page = e
      this.getTableList()
    },
    //获取列表
    getTableList() {
      this.tableConf.loading = true

      let startTime = '';
      let endTime = '';
      if(this.time!=null)
      {
        startTime = this.time[0];
        endTime = this.time[1];
      }
      getComByStreetIdApi({
        page: this.tableConf.page,
        limit: this.tableConf.size,
        streetId: this.id,
        startTime: startTime,
        endTime: endTime
      }).then((res) => {
        this.tableData = res.list
        this.tableConf.total = res.count
      }).finally(() => {
        this.tableConf.loading = false
      })
    },
    refreshTable() {
      this.tableConf.page = 1
      this.getTableList()
    }
  }
}
</script>
<style lang="scss" scoped>
.filterData-block {
  .el-form-item {
    margin-bottom: 0;
  }
}
</style>
